package code.rocky.chapter05;

import java.util.Arrays;

public class Suggest62 {
    public static void main(String[] args) {
        int balloonNum = 7;
        Balloon[] box1 = new Balloon[balloonNum];
        for (int i = 0; i < balloonNum; i++) {
            box1[i] = new Balloon(Color.values()[i], i);
        }
        Balloon[] box2 = Arrays.copyOf(box1, box1.length);
        box2[6].setColor(Color.Blue);
        for (Balloon balloon : box1) {
            System.out.println(balloon);
        }
    }
}

// 气球颜色
enum Color {
    Red, Orange, Yellow, Green, Indigo, Blue, Violet;
}

// 气球
class Balloon {
    // 编号
    private int id;

    // 颜色
    private Color color;

    public Balloon(Color _color, int _id) {
        color = _color;
        id    = _id;
    }

    public String toString() {
        return "编号: " + id + "颜色: " + color;
    }

    public void setColor(Color _color) {
        color = _color;
    }
}
